/**   
 * @Title: trackingrecordActGroup.java 
 * @Package: com.esun.rabbit2.viewer.mainact.mylotteryact.trackingrecord 
 * @Description: (追号记录列表ActivityGroup) 
 * @Author: Billy qigs@500wan.com   
 * @Date: 2011-7-20 下午12:36:03  
 * Copyright (C) 2011 Shenzhen E-sun Sky Net Technology Co.,ltd.
 */
package com.esun.rabbit2.viewer.mainact.mylotteryact.trackingrecord;

import android.app.ActivityGroup;
import android.content.Intent;
import android.os.Bundle;
import android.os.Message;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.RadioButton;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;

import com.esun.config.Config;
import com.esun.ui.R;

/**
 * @ClassName: trackingrecordActGroup
 * @Description: (追号记录列表ActivityGroup)
 * @Author: Billy qigs@500wan.com
 * @Date: 2011-7-20 下午12:36:03
 */
public class TrackingRecordActGroup extends ActivityGroup implements OnClickListener {

	private TabHost trackingrecordTabHost;
	private ImageButton btnBack;
	private RadioButton rbGoing;
	private RadioButton rbComplete;
	private RadioButton rbEnded;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.trackingrecord_act_group);

		initUI();
	}

	public void initUI() {

		trackingrecordTabHost = (TabHost) findViewById(R.id.trackingrecord_act_group_tabhost);
		trackingrecordTabHost.setup(getLocalActivityManager());

		// 进行中追号记录
		TabSpec goingtrackingrecord = trackingrecordTabHost.newTabSpec("Total_Chase_Record");
		goingtrackingrecord.setIndicator("0");
		goingtrackingrecord.setContent(new Intent(this, TrackingRecordGoingAct.class));
		trackingrecordTabHost.addTab(goingtrackingrecord);

		// 已完成追号记录
		TabSpec completedSeQiutrackingrecord = trackingrecordTabHost.newTabSpec("ShuangSeQiu_Chase_Record");
		completedSeQiutrackingrecord.setIndicator("1");
		completedSeQiutrackingrecord.setContent(new Intent(this, TrackingRecordCompletedAct.class));
		trackingrecordTabHost.addTab(completedSeQiutrackingrecord);

		// 已终止追号记录
		TabSpec endedToutrackingrecord = trackingrecordTabHost.newTabSpec("DaLeTou_Chase_Record");
		endedToutrackingrecord.setIndicator("2");
		endedToutrackingrecord.setContent(new Intent(this, TrackingRecordEndedAct.class));
		trackingrecordTabHost.addTab(endedToutrackingrecord);

		trackingrecordTabHost.setCurrentTab(0);

		rbGoing = (RadioButton) findViewById(R.id.trackingrecord_act_group_rb_going);
		rbGoing.setOnClickListener(this);

		rbComplete = (RadioButton) findViewById(R.id.trackingrecord_act_group_rb_complete);
		rbComplete.setOnClickListener(this);

		rbEnded = (RadioButton) findViewById(R.id.trackingrecord_act_group_agp_rb_end);
		rbEnded.setOnClickListener(this);

		btnBack = (ImageButton) findViewById(R.id.trackingrecord_act_group_btn_back);
		btnBack.setOnClickListener(this);

	}

	public static boolean isCanClick = true;

	@Override
	public void onClick(View v) {
		Message msg;
		switch (v.getId()) {
		case R.id.trackingrecord_act_group_rb_going:

			if (isCanClick) {
				trackingrecordTabHost.setCurrentTab(0);
				msg = TrackingRecordGoingAct.trackingRecordHandler.obtainMessage(Config.DO_REFRESH);
				TrackingRecordGoingAct.trackingRecordHandler.sendMessage(msg);
				isCanClick = false;
			}

			break;

		case R.id.trackingrecord_act_group_rb_complete:

			if (isCanClick) {
				trackingrecordTabHost.setCurrentTab(1);
				msg = TrackingRecordCompletedAct.trackingRecordHandler.obtainMessage(Config.DO_REFRESH);
				TrackingRecordCompletedAct.trackingRecordHandler.sendMessage(msg);
				isCanClick = false;
			}

			break;

		case R.id.trackingrecord_act_group_agp_rb_end:

			if (isCanClick) {
				trackingrecordTabHost.setCurrentTab(2);
				msg = TrackingRecordEndedAct.trackingRecordHandler.obtainMessage(Config.DO_REFRESH);
				TrackingRecordEndedAct.trackingRecordHandler.sendMessage(msg);
				isCanClick = false;
			}

			break;

		case R.id.trackingrecord_act_group_btn_back:

			TrackingRecordActGroup.this.finish();

			break;

		default:
			break;
		}
	}
}
